<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title><{:C('web_site_name')}>-后台管理</title>
<link rel="stylesheet" type="text/css" href="<?php echo APP_TMPL_PATH ; ?>/static/css/common.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo APP_TMPL_PATH ; ?>/static/css/main.css"/>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/layer/lib.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/layer/layer.min.js"></script>
</head>
<body>



<div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i>首页<span class="crumb-step">&gt;</span><span class="crumb-name">导航管理</span></div>
        </div>
        
        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                        <a href="javascript:void(0)" onclick="add()"><i class="icon-font"></i>新增导航</a>
                       
                    </div>
                </div>
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            
                            <th>ID</th>
                            <th>导航名称</th>
                            <th>pid</th>
                            <th>添加日期</th>
                            <th>排序</th>
                            <th>url</th>
                            <th>path</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        <?php 
                        	foreach($list as $key => $val){
                        ?>
                        <tr class="tr_<?php echo $val['path'];?>" >
                           
                            
                            <td><?php echo $val['id'];?></td>
                            <td title="<?php echo $val['name'];?>-点击收缩展开" style="cursor:pointer" onclick="toggle_div('<?php echo $val['id']?>','<?php echo $val['path']?>')"><?php echo $val['html'];?><font color="<?php echo $nav_color[$val['sort']];?>"><?php echo $val['name'];?></font>
                            </td>
                            <td><?php echo $val['pid'];?></td>
                            <td><?php echo $val['addtime'];?></td>
                            <td><input style="width:80px" class="common-text" placeholder="排序" name="disorder" value="<?php echo $val['disorder'];?>" type="text" attr-id="<?php echo $val['id'];?>" ></td>
                            <td><?php echo $val['url'];?></td>
                            <td><?php echo $val['path'];?></td>
                            <td><?php echo ($val['status'] == 1 )?"<font color='green'>开启</font>":"<font color='red'>关闭</font>";?></td>
                            <td>
                            	<a href="javascript:void(0)" onclick="add(<?php echo $val['id'];?>)"><i class="icon-font"></i></a>
                                 <a id="updateOrd" href="javascript:void(0)" onclick="edit(<?php echo $val['id'];?>)"><i class="icon-font"></i></a>
                                 <a id="batchDel" href="javascript:void(0)" onclick="del(<?php echo $val['id'];?>)"><i class="icon-font"></i></a>
                        
                            </td>
                        </tr>
                        <?php } ?>
                       
                    </table>
                </div>
            </form>
        </div>
       
        
    
   </body>
   </html>    
   
<script>
var loadding_0;
$(function(){
    $("input[name='disorder']").each(function(){
        $(this).blur(function(){
                 $.ajax({
                       type: "POST",
                       url: "<?php echo U('nav/edit');?>" ,
                       data: {"id":$(this).attr("attr-id") , 'action':'do_disorder' , 'disorder':$(this).val()},
                       cache:false,
                       dataType:"json",
                       async:true,
                       success: function(msg){
                           if(msg.resultcode != 1){
                              layer.msg(msg.resultinfo.errmsg);
                             return false ; 
                            }else{
                               
                            }
                            layer.close(loadding_0);
                       },
                       beforeSend:function(){
                               loadding_0 = layer.load('数据处理中....'); 
                       },
                       error:function(){
                               loadding_1 = layer.load('服务器繁忙请稍后等待。。。。。。'); 
                       }
                      
                    }); 
        });
    });
});
//添加导航
function add(pid){
	$.layer({
	    type: 2,
	    shadeClose: false,
	    title: false,
	    closeBtn: [0, true],
	    shade: [0.8, '#000'],
	    border: [1],
	    offset: ['20px',''],
	    area: ['720px','460px'],
	    iframe: {src: '<?php echo U("nav/add");?>&id='+pid+"&showpage=1"}
	}); 
}
function edit(id){
	$.layer({
	    type: 2,
	    shadeClose: false,
	    title: false,
	    closeBtn: [0, true],
	    shade: [0.8, '#000'],
	    border: [1],
	    offset: ['20px',''],
	    area: ['720px','460px'],
	    iframe: {src: '<?php echo U("nav/edit");?>&id='+id+"&showpage=1"}
	});
}
function del(id){

	$.layer({
	    shade: [0.8, '#000'],
	    area: ['240px','auto'],
	    shift: 'left', //从左动画弹出
	    dialog: {
	        msg: '确定删除数据吗？此操作不可恢复!',
	        btns: 2,                    
	        type: 4,
	        btn: ['确定','取消'],
	        yes: function(){
	        	$.ajax({
		 			   type: "POST",
		 			   url: "<?php echo U('nav/del');?>" ,
		 			   data: {"id":id},
		 			   cache:false,
		 			   dataType:"json",
		 			   async:true,
		 			   success: function(msg){
		 				   if(msg.resultcode != 1){
		 					  layer.msg(msg.resultinfo.errmsg);
							 return false ; 
		 					}else{
		 						window.location.href="<?php echo U('nav/index');?>";
		 					}
		 			   },
		 			   beforeSend:function(){
			 				  var loadding_0 = layer.load('数据处理中....'); 
		 			   },
		 			   error:function(){
			 				  var loadding_1 = layer.load('服务器繁忙请稍后等待。。。。。。'); 
		 			   }
		 			  
		 			});	
	            //layer.msg('重要', 1, 1);
	        }, no: function(){
	            
	        }
	    }
	});
}

function toggle_div(id , path ){
	
	var p = path+"-"+id ;
	//$("tr[class^='tr_"+p+"']").toggle();
	
}
</script>
        